package com.spsyry.pay.config;

import com.spsyry.pay.constatant.RabbitmqConstant;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;




//@Configuration
public class RabbitmqConfig {

    //队列
    @Bean
    public Queue createQueue() {
        return new Queue(RabbitmqConstant.MQ_QUEUE_NAME, true);
    }
    //交换机
    @Bean
    public DirectExchange createExchange(){
        return new DirectExchange(RabbitmqConstant.MQ_EXCHANGE_NAME);
    }
    //队列绑定到交换机，附带路由建
    @Bean
    public Binding createBinding(){
        return BindingBuilder.bind(this.createQueue()).to(this.createExchange()).with(RabbitmqConstant.MQ_ROUTING_KEY);
    }


}
